package ru.dadle8.model.bot.entity;

import lombok.Getter;
import lombok.Setter;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

@Getter
@Setter
public class MenuAction implements ActionType, Comparable<Object> {
    private String title;
    private int actionId;
    private int parentActionId;
    private int groupActionId;
    private int order;
    private int rowOrder;
    private List<MenuAction> childActions = new ArrayList<>();

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MenuAction that = (MenuAction) o;
        return Objects.equals(title, that.title);
    }

    @Override
    public int hashCode() {
        return Objects.hash(title);
    }

    @Override
    public int compareTo(Object o) {
        MenuAction that = (MenuAction) o;
        return Integer.compare(this.order, that.order);
    }

    @Override
    public int getType() {
        return 1;
    }

    public void addChildAction(MenuAction menuAction) {
        childActions.add(menuAction);
    }
}
